package com.blog.pojo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@ApiModel(description = "用户评论实体")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Review {
    //序列化
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("评论的id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("评论内容")
    private String content;

    @ApiModelProperty("创建该评论的用户id")
    private Long userId;

    @ApiModelProperty("评论的文章id")
    private Long articleId;

    @ApiModelProperty("创建评论的时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm")
    private LocalDateTime createTime;

    @ApiModelProperty("修改评论的时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm")
    private LocalDateTime updateTime;

    public void insertTime(){
        this.setCreateTime(LocalDateTime.now());
        this.setUpdateTime(LocalDateTime.now());
    }

    public void updateTime(){
        this.setUpdateTime(LocalDateTime.now());
    }
}
